<template>
  <div id="app">
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        <span>{{item}}</span>
        <button  @click="del(index)">删除</button>
      </li>
    </ul>

    <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
     
    };
  },

  mounted() {},

  methods: {
    fn() {
      let num = parseInt(Math.random() * 9);
      this.arr.push(num)
    },
    del(id) {
      this.arr.some((item, index) => {
        if (index == id) {
          this.arr.splice(index, 1);
          return true;
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>